Rust: Make path resolution tests work with Rust 1.96 and fix m::{self} when m is a trait - #22517
Open
paldepind wants to merge 3 commits into
Open
Rust: Make path resolution tests work with Rust 1.96 and fix m::{self} when m is a trait#22517paldepind wants to merge 3 commits into
m::{self} when m is a trait#22517paldepind wants to merge 3 commits into
Conversation
`m::{self}` where `m` is a struct errors since Rust 1.96:
- https://releases.rs/docs/1.96.0/#compatibility-notes
- rust-lang/rust#152996
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation matches Rust 1.96 semantics and includes focused valid and invalid regression coverage.
Review tier: Balanced
Findings: None
What changed in this PR
Updates Rust path resolution for Rust 1.96 compatibility and correctly handles {self} imports from traits.
Changes:
- Supports
{self}imports for modules, traits, and enums. - Moves the invalid struct case into invalid-code tests.
- Updates expected path-resolution results.
| File | Description |
|---|---|
PathResolution.qll |
Resolves trait {self} imports correctly. |
main.rs |
Tests all valid qualifier types. |
invalid/main.rs |
Tests the rejected struct qualifier. |
path-resolution.expected |
Updates generated expectations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
hvitved
approved these changes
Sep 7, 2026
hvitved
left a comment
Contributor
There was a problem hiding this comment.
LGTM; I have started a DCA run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since v1.96, Rust gives a compiler error for
m::{self}imports whenmresolves to a struct. The qualifier must resolve to a module, trait, or enum which has been made clear in the reference.We currently have a path resolution test that makes use of this and with 1.96+ this test is rejected by the compiler. This blocks what I'm trying to do over in #22493 with using a fixed Rust toolchain picked by the extractor.
This PR:
m::{self}whenmis a trait correctly. That is fixed by this PR.The invalid struct case still records a spurious result. Its inner
selfresolves to the enclosing module because of theelsebranch for"self"ingetASuccessor. Fixing that would be less trivial, and this PR is still a net improvement: before we had a spurious result for valid code and now we only have a spurious result for invalid code.